package com.daidaijie.moodnote.ui

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.daidaijie.moodnote.R
import com.daidaijie.moodnote.ext.to_ui
import io.reactivex.Observable
import java.util.concurrent.TimeUnit

class SplashActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)

        Observable.just(0)
                .delay(1, TimeUnit.SECONDS)
                .to_ui()
                .subscribe {
                    val intent = Intent(this@SplashActivity, MainActivity::class.java)
                    startActivity(intent)
                    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
                    this@SplashActivity.finish()
                }
    }

    override fun onBackPressed() {
    }
}
